import axios from 'axios';
let addGoodsAction = (name)=>{
    return {
        type:"ADD_GOODS",
        name:name
    }
}

let removeGoodsAction = (index)=>{
    return {
        type:"REMOVE_GOODS",
        index:index
    }
}
let getCartListAction = ()=>{
    
    return (dispatch)=>{
         // 发送异步请求获取购物车列表
    axios.get(`https://apif.java.crmeb.net/api/front/index/product/1/?page=1&limit=10`).then(res=>{
        console.log(res.data.data.list)
        dispatch({
            type:"SET_CARTLIST",
            list:res.data.data.list
        })
    })
    }
   
    // return {
    //     type:"SET_CARTLIST",
    //     list:[]
    // }
}
export {
    addGoodsAction,
    removeGoodsAction,
    getCartListAction
}